#!/bin/bash
# 这个脚本用于统计霸业主版37，联运，战略三个大平台的主服数,可根据时间来选择
inifile=/data/.slogin.profile

countqufu() {
	options=$4
	if [ $1 == "x" ];then
		#num=`awk -F, '{if($NF=="1")print $1,$2,$5}' $inifile | awk '{print $1,$2,$3}' | egrep '2345|liebao|yilewan|renrenwang|douyu|bdsp' $1 | wc -l`
		num=`awk -F, '{if($NF=="1")print $1,$2,$5}' $inifile | awk '{print $1,$2,$3}' | egrep $options "$2" | wc -l`
	else
		#num=`awk -F, '{if($NF=="1")print $1,$2,$5}' $inifile | awk -v dtime=$1 '{if($3<=dtime)print $1,$2,$3}' | egrep '2345|liebao|yilewan|renrenwang|douyu|bdsp' $1 | wc -l`
		#echo $1
		num=`awk -F, '{if($NF=="1")print $1,$2,$5}' $inifile | awk -v dtime=$1 '{if($3<=dtime)print $1,$2,$3}' | egrep $options "$2" | wc -l`
	fi
	echo "$3:$num"	
}

if [ -z "$2" ];then
	dtime='x'
else
	dtime=$2
fi

case $1 in
'37')
	countqufu $dtime '37wan' '37平台'
	;;
'zhanlue')
	countqufu $dtime "2345|liebao|yilewan|renrenwang|douyu|bdsp" "战略平台"
	;;
'lianyun')
	countqufu $dtime "2345|liebao|yilewan|renrenwang|douyu|bdsp|37wan" "联运平台" "-v"
	;;
'all')
	countqufu $dtime '37wan' '37平台'
	countqufu $dtime "2345|liebao|yilewan|renrenwang|douyu|bdsp" "战略平台"
	countqufu $dtime "2345|liebao|yilewan|renrenwang|douyu|bdsp|37wan" "联运平台" "-v"
	;;		
*)
	echo "`basename $0` 37wan|zhanlue|lianyun|all [time]" 
	;;
esac
